/*
 * Copyright (c) 2025 Li Auto Inc. and its affiliates
 * Licensed under the Apache License, Version 2.0(the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SIM_TAPDEV_H
#define SIM_TAPDEV_H

#include "veth.h"
#include "veth_internal.h"

#define CONFIG_SIM_NETDEV_NUMBER 1

typedef void (*txdone_cbk_ptr)(const uint8 ctrl_idx);
typedef void (*rxdone_cbk_ptr)(const uint8 ctrl_idx);

typedef struct {
    int devfd;
    uint8 rx_buf_total;
    uint8 tx_buf_total;
    uint16 tx_buf_len_byte;
    uint16 rx_buf_len_byte;
    uint8 curr_rx_buf_idx;
    veth_ctrl_status_type *ctrl_status_ptr;
    txdone_cbk_ptr txdone_cbk_func;
    rxdone_cbk_ptr rxdone_cbk_func;
} tap_dev_type;

extern sim_port_sem_t tap_send_sem;
Std_ReturnType tap_init(veth_core_ctrl_config_type *ctrl_cfg_ptr, veth_ctrl_status_type *ctrl_status_ptr,
            txdone_cbk_ptr txdone_cbk_func, rxdone_cbk_ptr rxdone_cbk_func);
Std_ReturnType tap_get_controller_mode(const uint8 ctrl_idx, eth_mode_type *ctrl_mode);
Std_ReturnType tap_set_controller_mode(const uint8 ctrl_idx, eth_mode_type const ctrl_mode);

#endif
